package com.itheima.itcasthealth.exception;

import com.itheima.itcasthealth.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(RuntimeException.class)
    public Result ex1(RuntimeException ex){
        log.info("出现RuntimeException...");
        ex.printStackTrace();
        return new Result(false,"系统繁忙,请稍后再访问",null);
    }
    @ExceptionHandler(Exception.class)
    public Result ex2(Exception ex){
        log.info("Exception...");
        ex.printStackTrace();
        return new Result(false,"系统繁忙,请稍后再访问",null);
    }
}
